package core.field;

import core.Player;
import core.PopUpBuy;


public class Territory extends Ownable {
	private int rent;
	
	public Territory(String name, int rent, int price){
		this.setName(name);
		this.setPrice(price);
		this.rent = rent;
	}

	public Territory() {
		
	}

	@Override
	public int getRent() {
		return rent;
	}

	@Override
	public void landOnField(Player player) {
		if(this.owner!=null){
			player.getKonto().withdrawPoints(getRent());
			this.owner.getKonto().addPoints(getRent());
		}
		else{
			if(new PopUpBuy().BuyFieldQ())
				this.buyField(player);
		}
		
	}
	
	
	public String toString(){
		String temp;
		temp = super.toString();
		return temp;
	}

	@Override
	public String subText() {
		String temp = ".";
		if(owner != null){
			temp = owner.getName();
			temp += String.valueOf(rent);
		}
		else
			temp = String.valueOf(price);
		return temp;
	}
		
	
	

}
